 /*******************************************************************
  **
  **  This file Has the key results of Conti Guzman
  **  results for Conti / Guzman.
  **/
  

/** Setup the Graphics Environment -- Very Important **/
set scheme s1mono

  
capture macro drop _all
capture log close _all
log using log/latest_run.log, replace text 

global r_summary_stats         1
global r_simple_graphs         1
global r_selection             0
global r_machine_learning      0
global r_store_ml_features     0
global r_balance_test_experiment     0
global r_intermediate_outcomes       1
global r_intermediate_outcomes_panel 1
global r_intermediate_oster    1
global r_patent_tests          1
global r_num_investors         1
global r_equity_outcomes       1
global r_equity_outcomes_panel 1
global r_equity_oster          1
global r_freyadelhoven_panel   1
global r_acquisition_and_vc    1
global r_patent_analysis       1
global r_types_of_ipo          1
global r_hazard_models         1
global r_acq_vs_ipo            1
global r_full_vs_partial_commitment    1
global r_by_destination_cross_section  1
global r_by_destination_outcomes       1
global r_quasi_experiment_robustness   1
global r_nonmover_quasi_exp_outcomes   1
global r_cease_to_operate 1
global r_appendix_cem     1
global r_appendix_year_outcomes 1

global r_dlasso_with_subsec_fe 1
    
/** Reviewer only stuff **/
global r_reviewer_table_subsector 1
global r_reviewer_per_period      1
global r_reviewer_ml_with_subsector 0
global r_reviewer_ml_subsector_features 0
global r_reviewer_equity_lasso 0


do label_variables.do
do selected_ml.do


/** Summary Statistics, Main Sample, Matched Sample ***/
if $r_summary_stats == 1 {
	//load_data ml , ignore_p_move
        use ml_cross_sectional.dta , replace
        
        label variable ml_n_patent "Initial Num. of Patents"
        label variable ml_n_us_inventor "Initial Num. US Inventors"
        label variable ml_n_il_inventor "Initial Num, Israeli Inventors"
        label variable ml_prof "Founder is University Professor"
        label variable ml_n_vc "First Round Num. of VC Investors"
        label variable ml_n_cvc "First Round Num. of Corp. VC Investors"
        label variable ml_n_angel_group "First Round Num. of Angel Group Investors"
        label variable ml_n_insurance_company "First Round Num. of Insurance Company Investors"
        label variable ml_n_private_equity "First Round Num. Private Equity Investors"
        label variable ml_n_bank "First Round Bank Num. Holding Investors"
        label variable ml_n_us_investor "First Round Num. US Investors"
        label variable ml_n_us_vc "First Round Num. US VCs"
        label variable ml_n_foreign_investor "First Round Num. Non-Israeli Investors"
        label variable ml_n_israeli_investor "First Round Num. Israeli Investors"
        label variable ml_n_foreign_vc "First Round Num. Non-Israeli VC"
        label variable ml_n_israeli_vc "First Round Num. Israeli VC"

        label variable univ_tto    		"University T.T.O. Investment (0/1)"
        label variable univ_spin   		"University Spinoff (0/1)"



        label variable cleantech   	        "Clean Tech (0/1)" 
        label variable comms       		"Communication Technology (0/1)" 
        label variable it_software 		"IT / Software (0/1)" 
        label variable internet     		"Internet (0/1)" 
        label variable life_science 		"Life Sciences (0/1)" 
        label variable medical_dev  		"Medical Devices (0/1)" 
        label variable misc         		"Hardware (0/1)" 
        label variable semicond     		"Semiconductor (0/1)" 
        label variable haifa        		"Haifa (0/1)" 
        label variable north        		"North (0/1)" 
        label variable center       		"Center (0/1)" 
        label variable west         		"West Bank (0/1)" 
        label variable jerusalem    		"Jerusalem (0/1)" 
        label variable telaviv      		"Tel Aviv (0/1)" 

        label variable  acquired "Acquired (0/1)"
        label variable  acquired_outside_US "Acquired Outside US (0/1)"
        label variable  ipo "IPO (0/1)"
        

        gen first_round_has_vc = ml_n_vc > 0
        
        gen investor_fe = .
        label variable investor_fe "Individual Investor Fixed-Effects"
        label variable industry "Industry"
        label variable location "Location"

        gen post_final_pat = final_pat - initial_pat
        gen post_final_trademarks = final_trademarks - initial_tr

        gen has_final_trademarks = post_final_trademarks > 0

        label variable has_final_trademarks "Applies for a Trademark (0/1)"
        label variable post_final_pat "Final Num. of Patents"
        

        sutex   n_ssfp n_founders univ_tto univ_spin   initial_tr   initial_pat    first_round_funding  investors_total investors_total_us investors_total_us_vc investors_total_non_us  us_vc_ moved migration_age cleantech comms it_software internet life_science medical_dev misc semicond haifa north center west jerusalem telaviv  ml_n_us_inventor ml_n_il_inventor ml_prof ml_n_vc ml_n_cvc ml_n_angel_group ml_n_insurance_company ml_n_private_equity ml_n_bank ml_n_us_investor ml_n_us_vc ml_n_foreign_investor ml_n_israeli_investor ml_n_foreign_vc ml_n_israeli_vc investor_fe foundation_year  industry location total_raised us_led_raised exit_amount acquired acquired_outside_US ipo us_ipo israel_ipo has_final_trademarks post_final_pat   , labels file(tex/summary_stats.tex) replace 



        label define mov_lbl 0 "Did Not Move to US" 1 "Moved to US"
        label values us_hq mov_lbl

        local summstats_vars  n_ssfp n_founders univ_tto univ_spin   initial_tr   initial_pat    first_round_funding  investors_total investors_total_us investors_total_us_vc investors_total_non_us  us_vc_   cleantech comms it_software internet life_science medical_dev misc semicond haifa north center west jerusalem telaviv  ml_n_us_inventor ml_n_il_inventor ml_prof ml_n_vc ml_n_cvc ml_n_angel_group ml_n_insurance_company ml_n_private_equity ml_n_bank ml_n_us_investor ml_n_us_vc ml_n_foreign_investor ml_n_israeli_investor ml_n_foreign_vc ml_n_israeli_vc  foundation_year   total_raised us_led_raised exit_amount acquired acquired_outside_US ipo us_ipo israel_ipo has_final_trademarks post_final_pat


        
        
        eststo clear
        estpost tabstat `summstats_vars' if foundation_year < 2003, by(us_hq) statistics(mean sd) columns(statistics)  nototal 

        esttab , main(mean) aux(sd) nostar unstack noobs nonote nomtitle nonumber label wide replace 
        
        esttab using "tex/appendix.summary_stats.period1.tex", main(mean) aux(sd) nostar unstack  nonote nomtitle nonumber label wide replace title("Summary statistics for firms founded 1990 to 2002.")

        eststo clear
        estpost tabstat `summstats_vars' if foundation_year >= 2003, by(us_hq) statistics(mean sd) columns(statistics)  nototal

        esttab , main(mean) aux(sd) nostar unstack noobs nonote nomtitle nonumber label wide replace 
        
        esttab using "tex/appendix.summary_stats.period2.tex", main(mean) aux(sd) nostar unstack  nonote nomtitle nonumber label wide replace title("Summary statistics for firms founded 2003 to 2014.")



}


if $r_simple_graphs == 1 { 
    //load_data flat , ignore_p_move
    use ml_cross_sectional.dta , replace
    set scheme s1mono
    graph bar (count) firm_id if us_hq_all  & migration_age <= 10, over(migration_age) ytitle("Count") title("Migration by age") saving(a.gph , replace) legend(off) 
    graph bar (count) firm_id if us_hq , over(migration_state, label(angle(90))) ytitle("Count") title("Migration by destination")  saving(b.gph , replace) legend(off)
	
    graph combine a.gph b.gph , rows(1) iscale(.7)
    graph export migration_by_age_dest.eps, replace
	

    set scheme s1mono
    
    //load_data flat , ignore_p_move
    use ml_cross_sectional.dta , replace
    gen log10_vc = log10(first_round_funding*1000000)
    
    
    twoway (hist log10_vc  if !us_hq  & log10_vc > 4 & first_round < 500 , frac xtitle("") bin(10) blcolor(blue) fcolor(blue) fintensity(30) lwidth(none))	(hist  log10_vc  if us_hq & log10_vc > 4  & first_round < 500,  frac  xtitle("") bin(10) fcolor(none) lwidth(thick)), xlabel(4 "10,000" 5 "100,000" 6 "1 Mill." 7 "10 Mill." 8 "100 Mill.")  legend(label(1 "Non-migrants") label(2 "Migrants"))  xtitle("Amount raised in first financing round ($)")
    
    graph export hist_of_VC_financing.eps, replace
    

    label define moved_lbl 0 "Non Migrant" 1 "Migrant"
    label values moved moved_lbl
    /*** Details on Migrants and non Migrants **/
    graph bar (mean) us_vc_r1 , over(moved, label(angle(45)) )  title("A. Share with US VC in first round") saving(a.gph, replace)  ytitle("Mean values")
    graph bar (mean) initial_pat , over(moved, label(angle(45)) )  title("B. Number of initial patents") saving(b.gph, replace) ytitle("Mean values")
    graph bar (mean) initial_tr , over(moved, label(angle(45)) )  title("C. Number of initial trademarks") saving(c.gph, replace) ytitle("Mean values")
    graph bar (mean) acquired , over(moved, label(angle(45)))  title("D. Share of startups acquired")   ytitle("Mean values") saving(d.gph, replace)

    graph bar (mean) exit_amount if acquired , over(moved, label(angle(45)))  title("E. Average acquisition amount") subtitle("Cond. on acquisition")    ytitle("mill. $") saving(e.gph, replace)
    
    graph bar (mean) ipo , over(moved, label(angle(45)))  title("F. Share of startups with IPO")   ytitle("Mean values") saving(f.gph, replace)
    
    graph combine a.gph b.gph c.gph d.gph e.gph f.gph, rows(2)  iscale(.5)
    graph export details_migrant_non_migrant.eps, replace 
    
    
    
    egen tot_movers = sum(us_hq)
    gen prop_mover = us_hq/tot_movers * 100

    replace industry = "Miscellaneous" if industry == "Hardware"
    graph bar (sum) prop_mover  , over(industry, label(angle(45))) ytitle("Percent of startups") title("A. Distribution of migrants by sector", size(medsmall))  saving(a.gph, replace)
    graph bar (sum) prop_mover , over(location, label(angle(45))) ytitle("Percent of startups") title("B. Distribution of migrants by founding location", size(medsmall))  saving(b.gph, replace)
    
    
    graph combine a.gph b.gph , cols(2)      ycommon   
    graph export distribution_ind_and_loc.eps, replace

    //load_data flat
    use ml_cross_sectional.dta , replace
    collapse (mean) us_hq p_move, by(foundation_year)
    keep if inrange(foundation_year, 1990, 2012)
    twoway line us_hq p_move foundation_year , title("") legend(label(1 "Share of Migrants") label(2 "Average Propensity to Migrate")) ytitle("Year") xtitle("") lpattern(solid dash)
    graph export propensity_to_move_and_moves.eps, replace

}


/**
 **
 ** Runs the results of the selection section.. Global switches at the top
 **/
do selection_results.do
 

/*** Impact of Migration
 ***
 ***   Intermediate outcomes:
 *        - cross sections: tex/impact_move_intermediate.tex
 *        - fixed-effects: tex/impact_move_intermediate_panel.tex
 *        - investors: tex/num_investors.tex
 ***
****/
if $r_intermediate_outcomes == 1{
    //load_data ml
    use ml_cross_sectional.dta , replace
    do selected_ml.do
    
    sum ones
    global total_obs `r(N)'
    
    egen year_loc = group(foundation_year location_code)
    
    gen moved_naive = us_hq
    gen moved_simple = us_hq
    gen moved_dd = us_hq
    gen moved_lasso = us_hq
    
    safedrop ln_first_round  has_trademarks ln_raised

    /** Adjust to remove the initial selection **/
    gen post_total_raised = total_raised - first_round
    gen post_final_pat = final_pat - initial_pat
    gen post_final_trademarks = final_trademarks - initial_tr


    gen ln_first_round = ln(first_round +1)
    gen ln_raised      = ln(post_total_raised +1)
    gen has_trademarks = post_final_trademarks > 0

    
    gen ln_pat = ln(post_final_pat + 1)

    eststo clear
    foreach depvar in  has_trademarks ln_pat ln_raised ln_raised_us_led   {

        local model_name `depvar'_
        local merged_name `depvar'_m
        di "Running models under `merged_name'" 
        
        **//eststo `model_name'_1:  reghdfe `depvar' moved_naive, absorb(ones) cluster(foundation_year  industry_code )
        
        
        local reg_naive reghdfe `depvar' moved_naive, noabsorb cluster(foundation_year  industry_code )
        eststo `model_name'_1:  `reg_naive'

        local r2_1 `e(r2)'
        
         if "${ml_`depvar'}" == "" {
            di "Running lasso for dep var = `depvar'"
            lassoShooting `depvar' ml_* ,  lasiter(100) verbose(0) controls(yr_*)
            file open f using selected_ml.do , write append
            file write f "global ml_`depvar' `r(selected)'" _n
            file close f
            do selected_ml.do
        }

        local us_hq_Selected ${ml_us_hq}
        local depvar_selected ${ml_`depvar'}
        local lasso_vars_dup  `us_hq_Selected' `depvar_selected'
        loc lasso_vars : list uniq lasso_vars_dup

        local reg_lasso reghdfe `depvar' moved_lasso  `lasso_vars'   , absorb(yr_* company_subsector) cluster(foundation_year  industry_code)
        eststo `model_name'_2: `reg_lasso'

        local r2_2 `e(r2)'
        
        

        eststo `model_name'_3: regress `depvar' moved_dd log_p_move c.log_p_move#c.log_p_move i.foundation_year if (strategic | moved_dd == 1) & in_p_move_range,vce(bootstrap)

        local r2_3 `e(r2)'
        
        global num_obs_did 126
        
        
        **/*** Lower Bound Estimate ***/


                
        di "Merging models under `merged_name'" 

        eststo `merged_name': appendmodels `model_name'_1 `model_name'_2   `model_name'_3 

        estadd scalar r2_1 = `r2_1'
        estadd scalar r2_2 = `r2_2'
        estadd scalar r2_3 = `r2_3'
    }





    esttab has_trademarks_m ln_pat_m ln_raised_m ln_raised_us_led_m     , keep(moved*)  mtitle("Trademarks" "Patents"  "Ln(VC \\$)" "Ln(VC US)")  label se refcat(moved_naive "Model 1: Naive" moved_simple "Model 2: Baseline"  moved_dd "Model 3: Quasi-Exp" moved_lasso "Model 4: LASSO", nolabel) replace noobs   varlabels(moved_naive "Moves to US" moved_matched "Moves to US" moved_dd "Moves to US") star(* .1 ** .05 *** .01) scalar(r2_1 r2_2 r2_3)
    

    
    esttab   has_trademarks_m ln_pat_m ln_raised_m ln_raised_us_led_m   using "tex/impact_move_intermediate.tex" , keep(moved*)  mtitle("\makecell{Applied for\\ Trademark}" "\makecell{Ln(Patents+1)}" "Ln(VC +1)" "\makecell{Ln(VC +1) \\(US VC Led Only)}")  label se refcat(moved_naive "\emph{Model I: Naive (N=$total_obs)}"   moved_dd "\emph{Model III: Quasi-Experiment (N=$num_obs_did)}" moved_lasso "\emph{Model II: Double-LASSO (N=$total_obs)}" , nolabel) replace noobs 	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large The effect of migrating to the US on Israeli startups' intermediate performance outcomes: Cross-sectional results}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the estimates for the impact of migrating on startup performance. We examine four intermediate outcomes. The first measure is an indicator for whether a startup applied for a trademark with the USPTO after \emph{t+1}, where \emph{t} is the startup's founding year (column (1)). The second measure is the number of US granted patents a startup applied for, again after \emph{t+1} (column (2)). The third and fourth outcomes are the amount of VC raised after the first financing round (column (3)) and the amount of US VC raised during the same period (column (4)), respectively. Model I is the naive model described in the text. Model II is the double-LASSO. Model III is our quasi-experiment exploiting exogenous institutional constraints on the startup's ability to migrate.  Model II controls for subsector and founding year fixed effects, while Model III only controls for founding year fixed effects. Standard errors (in parentheses) are double-clustered at founding year and sector levels for Models I and II, and bootstrapped for Model III. Significance denoted as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  varlabels(moved_naive "Moves to US"  moved_lasso "Moves to US" moved_dd "Moves to US") scalar("r2_1 R2 Model I" "r2_2 R2 Model II" "r2_3 R2 Model III") star(* .1 ** .05 *** .01) eqlabels(none) 



}

/**** Impact of migration:: Intermediate outcomes :: Panel Data **/

if $r_intermediate_outcomes_panel == 1 {
        use migration_panel.dta , replace
        
	replace moved_ = 0 if us_hq == 0
	drop if age > 7
	drop if us_sales_off | us_hq_all & !us_hq
	label variable moved_ "Has Moved"
	label variable age "Age"

        rename ln_cum_raised_us_led ln_r_us

        gen has_trademarks = ln_trademarks > 0
        xtset firm_id age
        
        //remove this line for old results
        //replace moved = age_move <= age 
                    
        forvalues i=0/7 {
            gen age_moved_`i' = moved & age == `i'
            label variable age_moved_`i' "Age = `i' X Has Moved"
        }

        gen moved_2sls = age_move <= age
        label variable moved_2sls "Has Moved"
        //eststo tsls_`v': ivreghdfe `v' moved_2sls (cum_investor = F.moved_), absorb( firm_id age age_move) cluster(foundation_year industry)

        /** Run the univariate models **/
    
	eststo clear
	foreach v of varlist ln_cum_raised ln_r_us ln_patents has_trademarks  {
            if "`v'" != "ln_cum_raised" {
		eststo single_var_`v': reghdfe `v' moved_, absorb(  firm_id age age_move) cluster(foundation_year industry)
            }
            else {
                eststo single_var_`v': reghdfe `v' moved_, absorb( firm_id age age_move) cluster(foundation_year)
            }

            local r2s_`v' `e(r2)'
	}
        

	foreach v of varlist  ln_cum_raised ln_r_us ln_patents has_trademarks {
		eststo agex_`v': reghdfe `v' age_moved_*, absorb( firm_id age age_move) cluster(foundation_year industry)	

                local r2p_`v' `e(r2)'
                
                test age_moved_0 age_moved_1 age_moved_2 age_moved_3 age_moved_4 age_moved_5 age_moved_6
                local F `r(F)'
                local p `r(p)'

                test  age_moved_1 age_moved_2 age_moved_3 age_moved_4 age_moved_5 age_moved_6
                local F1 `r(F)'
                local p1 `r(p)'

                
                eststo `v': appendmodels single_var_`v'  agex_`v'
                
                estadd scalar F `F'
                estadd scalar p `p'
                estadd scalar F1 `F1'
                estadd scalar p1 `p1'

                estadd scalar N _N

                estadd scalar r2_single=`r2s_`v''
                estadd scalar r2_panel=`r2p_`v''
	}


        esttab  has_trademarks ln_patents ln_cum_raised  ln_r_us   , se  stats(F p F1 p1 r2_single r2_panel, fmt(%9.2f %9.3g %9.0g) labels("F-Stat(5 , 7)"  "F-Stat p-value"))

	


        esttab  has_trademarks ln_patents ln_cum_raised  ln_r_us  using "tex/impact_move_intermediate_panel.tex" ,  keep(*moved*)  drop (*7*) mtitle( "\makecell{Applied for\\ Trademark}"  "Ln(Patents+1)" "Ln(VC+1)" "\makecell{Ln(VC+1) \\ (US VC Led Only)}"   )  label se 	refcat(moved_ "\emph{Model I: Main Difference}"  age_moved_0 "\emph{Model III: Movers Across Age}", nolabel) replace noobs prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 	"\caption{\large  The effect of migrating on Israeli startups' intermediate performance outcomes: Within-migrant variation}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the estimates for the impact of migrating on startup intermediary performance outcomes, exploiting within-migrant variation. We examine the same outcome variables as in Table 3. A startup's trademark (column (1)) and patent output (column (2)), as well as the amount of funding raised (columns (3) and (4)) are cumulative from founding. All regressions include startup fixed effects, age fixed effects, and age at migration fixed effects. Model I uses an indicator (\emph{Has Moved}) that takes on value 1 starting from the year in which a startup established its headquarters in the US and zero in the pre-migration period. Model II introduces interaction terms between the indicator \emph{Has Moved} and startup age dummies. Standard errors (in parentheses) are double-clustered at founding year and sector levels. Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01. " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")	   star(* .1 ** .05 *** .01) scalar("N Observations" "r2_single R2 Model I" "r2_panel R2 Model II")

} 


if $r_intermediate_oster == 1 {

    //load_data ml
    use ml_cross_sectional.dta , replace
    
    do selected_ml.do
    
    sum ones
    global total_obs `r(N)'
    
    egen year_loc = group(foundation_year location_code)
    
    gen moved_simple = us_hq    
    gen moved_lasso = us_hq
    
    safedrop ln_first_round  has_trademarks ln_raised

    /** Adjust to remove the initial selection **/
    gen post_total_raised = total_raised - first_round
    gen post_final_pat = final_pat - initial_pat
    gen post_final_trademarks = final_trademarks - initial_tr


    gen ln_first_round = ln(first_round +1)
    gen ln_raised      = ln(post_total_raised +1)
    gen has_trademarks = post_final_trademarks > 0

    
    gen ln_pat = ln(post_final_pat + 1)

    eststo clear
    foreach depvar in  has_trademarks  ln_raised ln_raised_us_led   {

        local model_name `depvar'_
        local merged_name `depvar'_m
        di "Running models under `merged_name'" 
        

        
        
        local reg_simple reghdfe `depvar' moved_simple, absorb(  foundation_year) cluster(foundation_year  industry_code )
        eststo `model_name'_1:  `reg_simple'

        
        local r2_simple `e(r2)'
        local b_simple = _b[moved_simple]


        if "${ml_`depvar'}" == "" {
            di "Running lasso for dep var = `depvar'"
            lassoShooting `depvar' ml_* ,  lasiter(100) verbose(0) controls(yr_*)
            file open f using selected_ml.do , write append
            file write f "global ml_`depvar' `r(selected)'" _n
            file close f
            do selected_ml.do
        }

        local us_hq_Selected ${ml_us_hq}
        local depvar_selected ${ml_`depvar'}
        local lasso_vars_dup  `us_hq_Selected' `depvar_selected'
        loc lasso_vars : list uniq lasso_vars_dup


        local reg_lasso reghdfe `depvar' moved_lasso  `lasso_vars'   , absorb(company_subsector yr_*) cluster(foundation_year  industry_code)
        eststo `model_name'_2: `reg_lasso'
        
        local r2_lasso `e(r2)'
        local b_lasso = _b[moved_lasso]

        
        
        **/*** Lower Bound Estimate ***/


        local r2_max = 1.42*`r2_lasso'
        
        local b_star = `b_lasso' - (`b_simple' - `b_lasso')*(`r2_max'-`r2_lasso')/(`r2_lasso' - `r2_simple')

        
        local delta =  `b_lasso' *  (`r2_lasso' - `r2_simple')/( (`b_simple' - `b_lasso')*(`r2_max'-`r2_lasso'))


                
        di "Merging models under `merged_name'" 

        eststo `merged_name': appendmodels `model_name'_1 `model_name'_2  

              
        estadd scalar r2_simple `r2_simple'
        estadd scalar r2_lasso `r2_lasso'

        estadd scalar r2_max `r2_max'
        estadd scalar b_star `b_star'
        estadd scalar delta `delta'

        
    }


        esttab   has_trademarks_m  ln_raised_m ln_raised_us_led_m , se refcat(moved_simple "\emph{Model I: Baseline (N=$total_obs)}"    moved_lasso "\emph{Model II: Double-LASSO (N=$total_obs)}" , nolabel) replace noobs scalar("r2_simple R2 Baseline Model" "r2_lasso R2 Lasso Model"  "r2_max R_max" "b_star $\beta^*$ (lower bound)" "delta delta") keep(moved_*)
    
        esttab   has_trademarks_m  ln_raised_m ln_raised_us_led_m   using "tex/oster_intermediate.tex" , keep(moved*)  mtitle("\makecell{Applied for\\ Trademark}"  "Ln(VC +1)" "\makecell{Ln(VC +1) \\(US VC Led Only)}")  label se refcat(moved_simple "\emph{Model I: Baseline (N=$total_obs)}"    moved_lasso "\emph{Model II: Double-LASSO (N=$total_obs)}" , nolabel) replace noobs 	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large Robustness test to assess the influence of unobservables on the startups' intermediate performance outcomes: Oster (2019) bounding method.}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: In this table, we implement the Oster (2019) bounding method to compute a lower bound for the migration effects on our intermediate outcomes. We derive the relationship between \$R_{max}\$--that is, the R-squared from a hypothetical regression of the outcome on the treatment and both observed and unobserved controls--and $\tilde{R}\$--that is, the R-squared from the controlled regression--from our machine learning model. To estimate the coefficient of proportionality, \$\pi\$, we consider that: i) if the outcome can be fully explained by the treatment and full controls set, \$R_{max}\$ is equal to 1; and ii) our controlled model explains approximately 70\% of the selection into migration; therefore iii) the coefficient of proportionality between Rmax and $\tilde{R}\$ we use is computed as \$\pi=1/0.7=1.43\$. In each column, the baseline specification controls for founding year and sector fixed effects, while the expanded specification includes all the double-LASSO controls. As shown, the lower bounds ($\beta$) of our estimates are all above zero. Moreover, the reported measure, $\delta$, for the relative degree of selection on observed and unobserved variables suggests that the influence of the unobservables relative to the observables would need to be over 2.8 times larger to produce a null migration effect. Standard errors (in parentheses) are double-clustered at founding year and sector levels. Significance noted as: *p \textless 0.10; **p  \textless 0.05; ***p \textless 0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  varlabels(moved_simple "Moves to US"  moved_lasso "Moves to US") star(* .1 ** .05 *** .01) eqlabels(none)  scalar("r2_simple R2 Baseline" "r2_lasso R2 LASSO"  "r2_max  R2 Max" "b_star $\beta^*$ (lower bound)" "delta $\delta$") 



}



/**** Impact of migration:: Intermediate outcomes :: Number of Investors **/

if $r_num_investors == 1 {
    //load_data ml
    use ml_cross_sectional.dta , replace
    eststo clear

    gen ln_inv_total = ln(investors_total)
    gen ln_inv_f_r = ln(investors_first_round)
    label variable ln_inv_f_r "Ln(Number of Initial Investors)"
 
    gen moved_lasso = us_hq
    gen moved_dd = us_hq
    gen ln_raised_lasso = ln_raised
    gen ln_raised_dd = ln_raised
    
    eststo clear

    foreach depvar in investors_total investors_total_us investors_total_us_vc investors_total_us_n_vc investors_total_non_us {

        if "${ml_`depvar'}" == "" {
            di "Running lasso for dep var = `depvar'"
            lassoShooting `depvar' ml_* ,  lasiter(100) verbose(0)
            file open f using selected_ml.do , write append
            file write f "global ml_`depvar' `r(selected)'" _n
            file close f
            do selected_ml.do
        }

        local us_hq_Selected ${ml_us_hq}
        local depvar_selected ${ml_`depvar'}
        local lasso_vars_dup  `us_hq_Selected' `depvar_selected'
        loc lasso_vars : list uniq lasso_vars_dup
 



        
         eststo `depvar'_2: reghdfe `depvar' moved_lasso `lasso_vars_dup'  i.investors_first  ln_raised_lasso, absorb(company_subsector yr_* ) cluster(foundation_year industry_code)

        eststo `depvar'_3: reghdfe `depvar' moved_dd   i.investors_first  ln_raised_dd c.log_p_move#c.log_p_move  if (strategic | moved_dd == 1) & in_p_move_range, cluster(foundation_year industry_code) absorb(foundation_year)

        eststo `depvar': appendmodels `depvar'_2 `depvar'_3
      
    }
    
    local us_hq_Selected ${ml_us_hq}
    local depvar_selected ${ml_investors_total}
    local lasso_vars_dup  `us_hq_Selected' `depvar_selected'

    eststo naive_investor_2: reghdfe investors_total moved_lasso `lasso_vars_dup'  i.investors_first  , absorb(company_subsector yr_* ) cluster(foundation_year industry )

    
    eststo naive_investor_3: reghdfe investors_total moved_dd   i.investors_first   c.log_p_move#c.log_p_move  if (strategic | moved_dd == 1) & in_p_move_range  , cluster(foundation_year industry_code) absorb(foundation_year)


    eststo naive_investor: appendmodels naive_investor_2 naive_investor_3
    
    esttab naive_investor investors_total investors_total_us investors_total_us_vc investors_total_us_n_vc investors_total_non_us , keep(moved_*)

    
    esttab naive_investor investors_total investors_total_us investors_total_us_vc investors_total_us_n_vc investors_total_non_us   using "tex/num_investors.tex" , se  keep(moved* ln_raised_*) order( moved_lasso ln_raised_lasso moved_dd ln_raised_dd)  mtitle( "\makecell{Total \\ Investors}" "\makecell{Total \\ Investors}" "\makecell{Total US \\ Investors}" "\makecell{Total US \\ Investors\\(VC Only)}" "\makecell{Total US \\ Investors\\(Non-VC)}" "\makecell{Total Non-US \\ Investors}")      varlabels(moved_lasso "Moves to US" moved_dd "Moves to US" ln_raised_lasso "Ln(VC+1)" ln_raised_dd "Ln(VC+1)") refcat( moved_dd "\emph{Model III: Quasi-experiment (N=126)}" ln_raised_dd "" moved_lasso "\emph{Model II:Double-LASSO (N=2179)}" ln_raised_lasso "" ,nolabel) label replace prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 	"\caption{\large  The effect of migrating on the number of unique total investors}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the effects of migrating on the number of unique investors participating in the startups' financing rounds (starting from the second round), \emph{having controlled for the total amount of funding raised}. In columns (1) and (2), we examine the total number of unique investors. In column (3), we consider the number of US investors as an outcome, while in column (4) we focus on the number of US VCs. In column (5), the outcome is the total number of US non-VC investors, while in column (6) we examine the total number of non-US investors. In all regressions, we include fixed effects for the number of unique investors participating in the startups' first round of financing. Model II includes founding year and subsector fixed effects, and Model III only founding year fixed effects. Standard errors (in parentheses) are double-clustered at founding year and sector levels for Model II and bootstrapped for Model III. Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01. " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")	   star(* .1 ** .05 *** .01) gaps nocons noobs


    /*** Now do as a panel ****/
    use migration_panel.dta , replace

    replace moved_ = 0 if us_hq == 0
    drop if age > 7
    drop if us_sales_off | us_hq_all & !us_hq
    label variable moved_ "Has Moved"
    label variable age "Age"

    rename cum_non_us_investor cum_non_us

    gen cum_non_us_vc = cum_us_investor - cum_us_vc_inv

    //replace moved = age_move <= age & age_move <= 4
    forvalues i=0/7 {
        gen age_moved_`i' = moved & age == `i'
        label variable age_moved_`i' "Age = `i' X Has Moved"
    }

    label variable ln_cum_raised "Ln(VC +1)"
        eststo clear

    foreach v of varlist cum_investor cum_us_investor cum_us_vc_inv cum_non_us_vc cum_non_us  {

        eststo single_var_`v': reghdfe `v' moved_ ln_cum_raised , absorb( firm_id age age_move) cluster(foundation_year)

	}
        
        /** Run the by year models **/

    foreach v of varlist cum_investor cum_us_investor cum_us_vc_inv cum_non_us_vc cum_non_us  {

        eststo agex_`v': reghdfe `v' age_moved_*  ln_cum_raised , absorb( firm_id age age_move) cluster(foundation_year industry)	
                
        eststo `v': appendmodels single_var_`v' agex_`v'
                
        estadd scalar N _N
    }


    esttab cum_investor cum_us_investor cum_us_vc_inv cum_non_us    , se  star(* .1 ** .05) mtitles("All Investors" "US Investors" "US VC" "Non US Investors")
    
    
    esttab cum_investor cum_us_investor cum_us_vc_inv cum_non_us_vc cum_non_us   using "tex/num_investors_panel.tex" ,  keep(*moved*)  drop (*7*) mtitle("\makecell{Total \\ Investors}" "\makecell{Total US \\ Investors}" "\makecell{Total US \\ Investors\\(VC Only)}" "\makecell{Total US \\ Investors\\(Non-VC)}" "\makecell{Total Non-US \\ Investors}" )  label se 	refcat(moved_ "\emph{Model I: Main Difference}" age_moved_0 "\emph{Model II: Movers Across Age}", nolabel) replace noobs prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 	"\caption{\large The effect of migrating to the US on the number of unique total investors: Within-migrant variation}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the effects of migrating on the number of unique investors participating in the startups financing rounds, having controlled for the cumulative amount of funding raised. In column (1), we examine the cumulative number of unique investors. In column (2), we consider the cumulative number of US investors, while in column (3) we focus on the cumulative number of US VCs. In column (4), the outcome is the cumulative number of US non-VC investors. All regressions include startup fixed effects, age fixed effects, and age at migration fixed effects. Model I uses an indicator (\emph{Has Moved}) that takes on value 1 starting from the year in which a startup established its headquarters in the US and zero in the pre-migration period. Model II introduces interaction terms between the indicator \emph{Has Moved} and startup age dummies. Standard errors (in parentheses) are double-clustered at founding year and sector levels for Model II and bootstrapped for Model III. Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01. " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")	   star(* .1 ** .05 *** .01)   stats( N, labels("Observations"))



    

}



/*** Impact of Migration
 ***
 ***   Equity outcomes:
 *        - cross sections: tex/impact_move_equity.tex
 *        - fixed-effects: tex/impact_move_equity_panel.tex
 *        - VC Financing Controls: tex/acquisition_and_vc.tex
 ***
****/
if $r_equity_outcomes == 1 {
    //load_data ml
    use ml_cross_sectional.dta  , replace

    sum ones
    global total_obs `r(N)'
    
    egen year_loc = group(foundation_year location_code)
    
    gen moved_naive = us_hq
    gen moved_simple = us_hq
    gen moved_lasso = us_hq
    gen moved_dd = us_hq

    gen ln_total_raised = ln(total_raised)
    
        /** First, load a bunch of important stuff necessary to run the regressions **/
    foreach depvar in  acquired ln_exit_amount  acquired_outside_US ipo {
         local model_name `depvar'_
        local merged_name `depvar'_m

         **//Model 1
        eststo `model_name'_1:  reghdfe `depvar' moved_naive, absorb(ones) cluster(foundation_year  industry_code )
        
        local r2_1 `e(r2)'
        
         if "${ml_`depvar'}" == "" {
            di "Running lasso for dep var = `depvar'"
            lassoShooting `depvar' ml_* ,  lasiter(100) verbose(0) controls(yr_*)
            file open f using selected_ml.do , write append
            file write f "global ml_`depvar' `r(selected)'" _n
            file close f
            do selected_ml.do
        }

        local us_hq_Selected ${ml_us_hq}
        local depvar_selected ${ml_`depvar'}
        local lasso_vars_dup  `us_hq_Selected' `depvar_selected'
        loc lasso_vars : list uniq lasso_vars_dup



        local reg_lasso reghdfe `depvar' moved_lasso  `lasso_vars'   , absorb(company_subsector yr_*) cluster(foundation_year  industry_code)
        eststo `model_name'_2: `reg_lasso'
         local r2_2 `e(r2)'
        

         
        if "`depvar'" != "ln_exit_amount" {
            eststo `model_name'_3: regress `depvar' moved_dd  log_p_move c.log_p_move#c.log_p_move i.foundation_year if (strategic | moved_dd == 1) & in_p_move_range , vce(bootstrap)
        }
        else {
            eststo `model_name'_3: regress ln_exit_amount moved_dd  if (strategic | moved_dd == 1) & in_p_move_range,  vce(bootstrap)
        }

        local r2_3 `e(r2)'         
        global num_obs_did 126


        
        di "Merging models under `merged_name'" 
        
        eststo `merged_name': appendmodels `model_name'_1 `model_name'_2   `model_name'_3 

         estadd scalar r2_1 = `r2_1'
         estadd scalar r2_2 = `r2_2'
         estadd scalar r2_3 = `r2_3'
    }

	


    esttab  acquired_m ln_exit_amount_m acquired_outside_US_m ipo_m    , keep(moved*)  mtitle( "1[Acquired]" "Ln(Exit \\$)" "1[Acquired Outside U.S.]" "1[IPO]")  label se refcat(moved_naive "Model 1: Naive" moved_matched "Model 2: Matching" moved_dd "Model 3: DiD", nolabel) replace noobs   varlabels(moved_naive "Moves to US" moved_matched "Moves to US" moved_dd "Moves to US") star(* .1 ** .05 *** .01)
	

	esttab   acquired_m acquired_outside_US_m ln_exit_amount_m  ipo_m  using "tex/impact_move_equity.tex" , keep(moved*)  mtitle( "Acquired" "\makecell{Acquired \\ by non-US firm}" "Ln(Exit \\$)"  "IPO")  label se refcat(moved_naive "\emph{Model I: Naive (N=$total_obs)}"    moved_dd "\emph{Model III: Quasi-Experiment (N=$num_obs_did)}" moved_lasso "\emph{Model II: Double-LASSO (N=$total_obs)}" , nolabel) replace noobs 	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large The effect of migrating to the US on Israeli startups' equity outcomes: Cross sectional results}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the estimates for the impact of migrating on four startup equity outcomes. The outcomes are: the likelihood that a startup is acquired (column (1)), the likelihood it is acquired by a non-US company (column (2)), a startups' sales value (column (3)), and the likelihood it exits through an IPO (column (4)). Model I is the naive model described in the text. Model II is the double-LASSO. Model III is our quasi-experiment. Model II includes founding year and subsector fixed effects, and Model III founding year fixed effects. Model III in column (3) does not include founding year fixed effects  given that the sample size is only 36 and the main effect cannot be identified. Standard errors (in parentheses) are double-clustered at founding year and sector levels for Models I and II, and bootstrapped for Model III. Significance denoted as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  varlabels(moved_naive "Moves to US"  moved_lasso "Moves to US" moved_dd "Moves to US") star(* .1 ** .05 *** .01) eqlabels(none)  scalar("r2_1 R2 Model I" "r2_2 R2 Model II" "r2_3 R2 Model III")



}





if $r_equity_outcomes_panel == 1 {
    use migration_panel.dta , replace

    
	replace moved_ = 0 if us_hq == 0
	drop if age > 7
	drop if us_sales_off | us_hq_all & !us_hq
	label variable moved_ "Has Moved"
	label variable age "Age"

	rename ln_cum_raised_us_led ln_r_us

        //remove this line for old results
        //replace moved = age_move <= age & age_move <= 4

        forvalues i=0/7 {
            gen age_moved_`i' = moved & age == `i'
            label variable age_moved_`i' "Age = `i' X Has Moved"
        }
        gen moved_2sls =age_move <= age 
        label variable moved_2sls "Has Moved"
        
        xtset firm_id age 
        
	eststo clear
        /** Run the univariate models **/
	foreach v of varlist acquired_  acq_not_us_ ipo_  {
            if "`v'" != "ln_cum_raised" {
		eststo single_var_`v': reghdfe `v' moved_, absorb( firm_id age age_move) cluster(foundation_year industry)        
            }
            else {
                eststo single_var_`v': reghdfe `v' moved_, absorb( firm_id age age_move) cluster(foundation_year)
            }

            local r2s_`v' `e(r2)'
	}
        
        /** Run the by year models **/
	foreach v of varlist acquired_  acq_not_us_ ipo_  {
		eststo agex_`v': reghdfe `v' age_moved_*, absorb( firm_id age age_move) cluster(foundation_year industry)	

                local r2p_`v' `e(r2)'
                
                test age_moved_0 age_moved_1 age_moved_2 age_moved_3 age_moved_4 age_moved_5 age_moved_6
                local F `r(F)'
                local p `r(p)'

                test  age_moved_1 age_moved_2 age_moved_3 age_moved_4 age_moved_5 age_moved_6
                local F1 `r(F)'
                local p1 `r(p)'

                
                eststo `v': appendmodels single_var_`v'  agex_`v'
                
                estadd scalar F `F'
                estadd scalar p `p'
                estadd scalar F1 `F1'
                estadd scalar p1 `p1'

                estadd scalar N _N

                
                estadd scalar r2_single=`r2s_`v''
                estadd scalar r2_panel=`r2p_`v''

	}


        esttab acquired_  acq_not_us_ ipo_   , se  stats(F p F1 p1, fmt(%9.2f %9.3g %9.0g) labels("F-Stat(5 , 7)"  "F-Stat p-value"))


        esttab acquired_  acq_not_us_ ipo_  using "tex/impact_move_equity_panel.tex" ,  keep(*moved*)  drop ( *7* ) mtitle( "Acquired" "\makecell{Acquired \\ by non-US Firm}" "IPO"  )  label se 	refcat(moved_ "\emph{Model I: Main Difference}" moved_2sls "\emph{Model II:Freyaldenhoven et al (2019) 2SLS}"  age_moved_0 "\emph{Model III: Movers Across Age}", nolabel) replace noobs prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 	"\caption{\large The effect of migrating to the US on Israeli startups' equity outcomes: Within-migrant variation}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the estimates for the impact of migrating on three startup equity outcomes, exploiting within-migrant variation. Columns (1) and (2) examine a startup's acquisition events, while Column (3) assesses the likelihood that the startup will have exited via an IPO, as of a given year. All regressions include startup fixed effects, age fixed effects, and age at migration fixed effects. Model I uses an indicator (\emph{Has Moved}) that takes on value 1 starting from the year in which a startup established its headquarters in the US and zero in the pre-migration period. Model II introduces interaction terms between the indicator \emph{Has Moved} and startup age dummies. Standard errors (in parentheses) are double-clustered at founding year and sector levels. Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01. " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")	   star(* .1 ** .05 *** .01) scalar("N Observations" "r2_single R2 Model I" "r2_panel R2 Model II")

} 





if $r_freyadelhoven_panel == 1 {
       use migration_panel.dta , replace
	replace moved_ = 0 if us_hq == 0
	drop if age > 7
	drop if us_sales_off | us_hq_all & !us_hq
	label variable moved_ "Has Moved"
	label variable age "Age"

	rename ln_cum_raised_us_led ln_r_us

        xtset firm_id age
             
        replace moved_ = age_move <= age
        gen has_trademarks = ln_trademarks > 0
        gen has_patents = ln_pat > 0

        gen exit = acquired_ | ipo_
        
        gen acquired_us = acquired_ & !acq_not_us_

        gen lcum_inv = log(cum_investor + 1)
        
	eststo clear
	foreach v of varlist acquired_ acq_not_us_ ipo_  exit  {
            eststo `v': ivreghdfe `v' moved_ (  lcum_inv   =F.moved_   ) , absorb( firm_id age age_move ) cluster(foundation_year )

            local u1 `e(idstat)'
            estadd scalar u1 `u1'
        }


        esttab    , se  stats(F p F1 p1, fmt(%9.2f %9.3g %9.0g) labels("F-Stat(5 , 7)"  "F-Stat p-value")) star(* .1 ** .05)

        
        esttab    using "tex/appendix.freyaldenhoven_effect.tex" ,  keep(*moved*)   mtitle( "Acquired" "\makecell{Acquired \\ by non-US Firm}" "IPO"  "Exit")  label se 	 replace noobs prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 	"\caption{\large Instrumental variables results on equity outcomes} " "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the 2SLS estimates for the impact of migrating on startup equity outcomes, exploiting within-migrant variation. We include fixed effects for each startup,  startup age, and age at migration.  We also control for time-varying differences in a startup's initial traction using the total number of investors that have invested in a startup over time. We instrument this variable with the first lead of the \emph{Has Moved} indicator as recommended by Freyaldenhoven \emph{et al.} (2019). StanDard errors (in parentheses) are clustered by founding year. Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01. " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")	   star(* .1 ** .05 *** .01)   stats( N u1, labels("Observations" "Underidentification Test"))

        

       use migration_panel.dta , replace
	replace moved_ = 0 if us_hq == 0
	drop if age > 7
	drop if us_sales_off | us_hq_all & !us_hq
	label variable moved_ "Has Moved"
	label variable age "Age"

	rename ln_cum_raised_us_led ln_r_us

        xtset firm_id age
             
        replace moved_ = age_move <= age
        gen has_trademarks = ln_trademarks > 0
        gen has_patents = ln_pat > 0

        gen exit = acquired_ | ipo_
        
        gen acquired_us = acquired_ & !acq_not_us_

        gen lcum_inv = log(cum_investor + 1)
        




        gen move_year = L.moved_ == 0 & moved_ == 1
        gen t_move = 100 if move_year== 1
        
        forvalues i=1/10 {
            replace t_move = 100 + `i' if L`i'.move_year == 1
            replace t_move = 100 - `i' if F`i'.move_year == 1

            gen pre_move_`i' = F`i'.move_year == 1
            gen post_move_`i' = L`i'.move_year == 1
        }


        save pre_year_freyaldenhoven_coefs.dta , replace


        

        use pre_year_freyaldenhoven_coefs.dta , replace

        ivreghdfe acquired_ pre_move_5  pre_move_4  pre_move_3  pre_move_2  pre_move_1 post_move_1 post_move_2 post_move_3  post_move_4 post_move_5 post_move_6 post_move_7 (lcum_inv = F.moved_)   , absorb( firm_id age age_move ) cluster(foundation_year )
        parmest , saving(freyaldenhoven_t_coefs.dta , replace)

        sum acquired_
        replace acquired_ = acquired_ / `r(mean)'

        sum lcum_inv
        replace lcum_inv = lcum_inv / `r(mean)'

        
        parmby "reghdfe acquired_ ib0.t_move , absorb( firm_id age age_move ) cluster(foundation_year )", saving(fr_acq.dta , replace)

        parmby "reghdfe lcum_inv ib0.t_move , absorb( firm_id age age_move ) cluster(foundation_year )", saving(fr_cum_inv.dta , replace)        


        
        clear
        use fr_acq.dta , replace

        gen time = subinstr(parm,".t_move", "" , .)
        replace time = subinstr(time,"b","",.)
        destring time, replace force
        drop if time == . 
        
        sum estimate if time == 100
        local x1 = `r(mean)'

        sum estimate if time <= 100 & time != 0
        local x2 = `r(sd)'
        
        foreach v of varlist estimate min95 max95 {
            replace `v' = (`v' - `x1')/`x2'
            rename `v' acq_`v'
        }
        save fr_acq.dta , replace

        
        clear
        use fr_cum_inv.dta , replace
      
        gen time = subinstr(parm,".t_move", "" , .)
        replace time = subinstr(time,"b","",.)
        destring time, replace force
        drop if time == . 

        
        sum estimate if time == 100
        local x1 = `r(mean)'

        sum estimate if time <= 100  & time != 0
        local x2 = `r(sd)'
        
        foreach v of varlist estimate min95 max95 {
            replace `v' = (`v' - `x1')/`x2'
            rename `v' cum_`v'
        }
        
        merge 1:1 time using fr_acq.dta         
        gen acq_time = time + .2

        list time cum* acq*

        drop if time < 94 | time == 100

        replace time = time - 100
        replace acq_time = acq_time - 100

        set scheme s1mono
        twoway (scatter  cum_estimate time , mcolor(red)) (rcap cum_min95 cum_max95 time ,lcolor(red)) (scatter acq_estimate acq_time ,ms(Oh) mcolor(blue))  , title("A. Overlay of  acquisition outcome and rescaled" "uneffected covariate (log number of investors)" "around event time", size(smallmed)) legend(order(1 3) label(1 "Number of Investors (log)") label(3 "Acquisition")) xtitle("Time from/to migration") yline(0) saving(a.gph, replace)

       


        clear
        use freyaldenhoven_t_coefs.dta , replace

        replace parm = subinstr(parm,"pre_move_","-",.)
        replace parm = subinstr(parm,"post_move_","",.)
       destring parm, replace force
        drop if parm == .
        drop if parm == 5

        set scheme s1mono
        twoway (scatter estimate parm) (rcap min95 max95 parm), title("B. Acquisition outcome around event time, using the" "behavior of the number of investors to net" "out the effect of the counfound", size(smalllmed)) xtitle("Time from/to migration") ytitle("Probability of Acquisition") yline(0) legend(off) saving(b.gph, replace)


        graph combine a.gph b.gph , iscale(.6)

        
        
          graph export main_effect_freyaldenhoven.eps, replace
} 



if $r_acquisition_and_vc== 1 {
    //load_data ml
    use ml_cross_sectional.dta , replace

    gen acquired_in_us = acquired & !acquired_outside_
    gen ln_investors_us_vc = ln(investors_total_us_vc + 1)
    gen ln_investors_us_non_vc = ln(investors_total_us_n_vc + 1)
    
    eststo clear
    eststo: reghdfe ln_exit us_hq if acquired_in_us , absorb(foundation_year industry_code location company_subsector )  cluster(foundation_year industry_code)
    eststo: reghdfe ln_exit us_hq  ln_raised  if acquired_in_us , absorb(foundation_year industry_code location company_subsector )  cluster(foundation_year industry_code)
    eststo: reghdfe ln_exit us_hq ln_raised  c.ln_raised#c.ln_raised  us_vc_r1 ln_investors_us_vc ln_investors_us_non_vc has_pat has_trademark incubator_grl univ_spin n_founders if acquired_in_us , absorb(  foundation_year industry_code location company_subsector )  cluster(foundation_year industry_code) 

    esttab, drop(has_pat has_trademark incubator_grl univ_spin n_founders) star(* .1 ** .05)
    
 

    esttab    using "tex/acquisition_and_vc.tex" ,  drop(has_pat has_trademark incubator_grl univ_spin n_founders _cons) mtitle( "Ln(Exit \\$)" "Ln(Exit \\$)"   "Ln(Exit \\$)"   )  refcat( ln_raised  " " c.ln_raised#c.ln_raised  " "   us_vc_r1  " "  ln_investors_us_vc  " "  ln_investors_us_non_vc  " ", nolabel) label se varlabel(us_hq "Moves to US" ln_raised "Ln(Total VC Raised \$ +1)" c.ln_raised#c.ln_raised "Ln(Total VC Raised \$ +1)^2" us_vc_r1 "Has US VC in First Round" ln_investors_us_vc "Ln(Total Unique US VC Investors +1)" ln_investors_us_non_vc "Ln(Total Unique US Non VC Investors +1)")  replace  prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 	"\caption{\large The role of the market for acquisitions as a source of the US entrepreneurial ecosystem's comparative advantage - Controlling for venture capital financing in startups acquired by US companies}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports regressions results for the impact of migrating to the US on the startups' acquisition price. We restrict the sample to startups acquired by US companies and control for multiple VC characteristics, and the financing amount received. All regressions include indicators for whether startups had applied for a US granted patent or a trademark at founding, for whether startups are university spinoffs, and for whether they spent time in a government-sponsored incubator. We also control for the number of founders and include founding year, subsector, and founding location fixed effects. The coefficient of \emph{Moves to US} in column (3) can be suggestively interpreted the effect of the US market for acquisitions as a source of the US comparative advantage in entrepreneurship, having controlled for the role of VC financing. Standard errors (in parentheses) are double-clustered at founding year and sector levels.  Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01. " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")	   star(* .1 ** .05 *** .01)   r2 nocons gaps

    
}




if $r_equity_oster == 1 {

    //load_data ml
    use ml_cross_sectional.dta , replace
    do selected_ml.do
    
    sum ones
    global total_obs `r(N)'
    
    egen year_loc = group(foundation_year location_code)
    
    gen moved_simple = us_hq    
    gen moved_lasso = us_hq
    

    gen acquired_US = acquired & !acquired_outside_US
    eststo clear
    foreach depvar in acquired acquired_US ln_exit_amount  {

        local model_name `depvar'_
        local merged_name `depvar'_m
        di "Running models under `merged_name'" 
        

        
        
        local reg_simple reghdfe `depvar' moved_simple, absorb( foundation_year) cluster(foundation_year  industry_code )
        eststo `model_name'_1:  `reg_simple'

        
        local r2_simple `e(r2)'
        local b_simple = _b[moved_simple]


        if "${ml_`depvar'}" == "" {
            di "Running lasso for dep var = `depvar'"
            lassoShooting `depvar' ml_* ,  lasiter(100) verbose(0) controls(yr_*)
            file open f using selected_ml.do , write append
            file write f "global ml_`depvar' `r(selected)'" _n
            file close f
            do selected_ml.do
        }

        local us_hq_Selected ${ml_us_hq}
        local depvar_selected ${ml_`depvar'}
        local lasso_vars_dup  `us_hq_Selected' `depvar_selected'
        loc lasso_vars : list uniq lasso_vars_dup


        local reg_lasso reghdfe `depvar' moved_lasso  `lasso_vars'   , absorb(company_subsector  yr_*) cluster(foundation_year  industry_code)
        eststo `model_name'_2: `reg_lasso'
        
        local r2_lasso `e(r2)'
        local b_lasso = _b[moved_lasso]

        
        
        **/*** Lower Bound Estimate ***/


        local r2_max = 1.42*`r2_lasso'
        
        local b_star = `b_lasso' - (`b_simple' - `b_lasso')*(`r2_max'-`r2_lasso')/(`r2_lasso' - `r2_simple')

        
        local delta =  `b_lasso' *  (`r2_lasso' - `r2_simple')/( (`b_simple' - `b_lasso')*(`r2_max'-`r2_lasso'))


                
        di "Merging models under `merged_name'" 

        eststo `merged_name': appendmodels `model_name'_1 `model_name'_2  

              
        estadd scalar r2_simple `r2_simple'
        estadd scalar r2_lasso `r2_lasso'


        estadd scalar r2_max `r2_max'
        estadd scalar b_star `b_star'
        estadd scalar delta `delta'
        
    }


    esttab acquired_m acquired_US_m ln_exit_amount_m , se refcat(moved_simple "\emph{Model I: Baseline (N=$total_obs)}"    moved_lasso "\emph{Model II: Double-LASSO (N=$total_obs)}" , nolabel) replace noobs scalar("r2_simple R2 Baseline Model" "r2_lasso R2 Lasso Model"  "r2_max R_max" "b_star $\beta^*$ (lower bound)" "delta delta") keep(moved_*)
    


    esttab acquired_m acquired_US_m ln_exit_amount_m  using "tex/oster_equity.tex"    , keep(moved*)  mtitle( "Acquired" "\makecell{Acquired  \\ by US firm}" "Ln(Exit \\$)" ) label se refcat(moved_simple "\emph{Model I: Baseline (N=$total_obs)}"    moved_lasso "\emph{Model II: Double-LASSO (N=$total_obs)}" , nolabel) replace noobs 	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large Robustness test to assess the influence of unobservables on the startups' equity outcomes: Oster (2019) bounding method}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: In this Table, we implement the Oster (2019) bounding method to compute a lower bound for the migration effects on our startup equity outcomes. As shown, the lower bounds of our migration effects ($\beta$) are all above zero. Moreover, the reported $\delta$ for these equity outcomes suggests that the influence of unobservables relative to observables would need to be over 1.1 times larger to produce a null migration effect. Significance noted as: *p \textless 0.10; **p \textless 0.05; ***p \textless 0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  varlabels(moved_simple "Moves to US"  moved_lasso "Moves to US") star(* .1 ** .05 *** .01) eqlabels(none)  scalar("r2_simple R2 Baseline" "r2_lasso R2 LASSO"  "r2_max R2 Max" "b_star \$\beta^*\$ (lower bound)" "delta \$\delta\$") 



}


/***********************
####
##          _END_ OF MAIN RESULTS
###
***************************/


/************   Types of IPO *****************/
if $r_types_of_ipo == 1 { 
    //load_data ml
    use    ml_cross_sectional.dta , replace
    
    
    gen moved_lasso = us_hq
    gen moved_dd = us_hq

    eststo clear
    foreach depvar of varlist ipo us_ipo israel_ipo {
        eststo `depvar'_1: reghdfe `depvar' moved_lasso $ml_us_hq ${ml_`depvar'}, absorb(company_subsector  foundation_year ) cluster(foundation_year industry )
        eststo  `depvar'_2: areg `depvar' moved_dd   log_p_move c.log_p_move#c.log_p_move  if (strategic == 1 | us_hq == 1) & in_p_move_range, absorb(foundation_year ) vce(bootstrap)
        eststo  `depvar'_m: appendmodels  `depvar'_1  `depvar'_2
    }
    
    esttab ipo_m us_ipo_m israel_ipo_m, se r2 mtitle("IPO" "US IPO" "TASE" "NASDAQ" "NYSE") star(* .1 ** .05 *** .01) keep(moved_*)


    esttab  ipo_m us_ipo_m israel_ipo_m using "tex/types_of_ipo.tex" , se    mtitle( "IPO" "US IPO" "Israel (TASE) IPO"   )  keep(moved_*) varlabels(moved_lasso "Moves to US" moved_dd "Moves to US") refcat( moved_lasso "\emph{Model II: Double-LASSO}"  moved_dd "\emph{Model III: Quasi-Experiment}", nolabel) label replace prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 	"\caption{\large The effect of migrating to the US on the Israeli startups' likelihood of exiting via an IPO, differentiating by Stock Exchange}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the estimates of the effect of migrating to the US on the likelihood of exiting via an IPO. We distinguish between those IPOs that took place on the US stock exchanges (NASDAQ and NYSE) and those that occurred on the Tel Aviv stock exchange (TASE). Model II includes founding year and subsector fixed effects, and Model III only founding year fixed effects. Standard errors (in parentheses) are double-clustered at founding year and sector levels in Model II, and bootstrapped in Model III. Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01. " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}") noobs gaps star(* .1 ** .05 *** .01)


}


/***********************************
*******   Partial vs full commitment strategies
************************************/

if $r_full_vs_partial_commitment == 1 {
	 
    /** First, load a bunch of important stuff necessary to run the regressions **/
    //load_data ml_all
    use ml_cross_sectional.dta , replace
    
    label variable us_hq "HQ in US"
    label variable us_sales_off "Branch in the US"
    label variable acquired "Acquired"

    /*keep if strategic | us_hq | us_sales_off*/
    
    drop if us_hq_all & !us_hq

    capture gen has_pat = initial_pat > 0
    
    /** Adjust to remove the initial selection **/
    gen post_total_raised = total_raised - first_round
    gen post_final_pat = final_pat - initial_pat
    gen post_final_trademarks = final_trademarks - initial_tr

    safedrop ln_first_round ln_raised has_trademarks
    gen ln_first_round = ln(first_round +1)
    label variable ln_first_round "Ln(First round amount mill.\\$ +1)"

    gen ln_raised      = ln(post_total_raised +1)
    gen has_trademarks = post_final_trademarks > 0

    gen acquired_non_US = acquired & !acquirer_is_us


    local us_hq_Selected ${ml_us_hq}
    local depvar_selected ${ml_post_final_pat}
    local lasso_vars_dup  `us_hq_Selected' `depvar_selected'

    loc lasso_vars : list uniq lasso_vars_dup
 
    randomforest post_final_pat `lasso_vars' , gen(pred_pat)

    capture drop __p*
    gen __p1 = pred_pat
    gen __p2 = __p1^2
    gen __p3 = __p1^3

    
    

    eststo clear

    eststo:  reghdfe has_trademarks  us_hq us_sales_off $ml_has_trademarks $ml_us_hq , absorb( company_subsector  yr_*) cluster(foundation_year industry)

    gen ln_pat = ln(post_final_pat+1)
      eststo:  reghdfe ln_pat  us_hq us_sales_off $ml_has_trademarks $ml_us_hq , absorb(company_subsector  yr_*) cluster(foundation_year industry)
 
    eststo:  reghdfe ln_raised  us_hq us_sales_off $ml_us_hq $ml_ln_raised  , absorb(company_subsector  yr_*) cluster(foundation_year industry )
    eststo:  reghdfe ln_raised_us_led  us_hq  us_sales_off $ml_us_hq $ml_ln_raised_us_led , absorb(yr_*) cluster(foundation_year industry)

    /*** Impact on equity outcomes ***/
   
    eststo:  reghdfe acquired  us_hq  us_sales_off $ml_us_hq $ml_acquired , absorb(company_subsector  yr_*) cluster(foundation_year industry)
    eststo:  reghdfe acquired_non_US  us_hq us_sales_off $ml_us_hq $ml_acquired_non_US , absorb(company_subsector yr_*) cluster(foundation_year industry)
    eststo:  reghdfe ln_exit_amount us_hq us_sales_off   $ml_us_hq $ml_ln_exit_amount , absorb(company_subsector ones) cluster(foundation_year industry )
    eststo:  reghdfe ipo us_hq us_sales_off $ml_us_hq $ml_ipo , absorb(company_subsector  ones) cluster(foundation_year  industry)

    esttab,  drop(ml* *cons*)
    esttab using tex/off_vs_hq.tex ,   mtitle( "\makecell{Applied for\\ Trademark}" "\makecell{Ln(Patents+1)}"  "Ln(VC +1)" "\makecell{Ln(VC+1) \\ (US VC-Led Only)}" "Acquired" "\makecell{Acquired \\ by non-US Firms}"  "Ln(Exit \\$)" "IPO") drop(ml* yr_27 *cons*)  varlabels(us_hq "Moves to US" us_sales_off "Opens Subsidiary in US"    ) se replace  refcat(us_sales_off "", nolabel) prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large Headquarter migration versus the opening of a branch}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table compares the performance of each migrant type, namely the startup establishing its headquarters in the US and the one opening a branch, to that of non-migrants.  We present the results from the double-LASSO models. We examine the same startup performance outcomes as those investigated in Table 3 and Table 6. Standard errors (in parentheses) are double-clustered at founding year and sector levels. Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01. " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  star(* .1 ** .05 *** .01) order(us_hq us_sales_off) eqlabels(none) r2 


}

/*** Something by destination ***/

if $r_by_destination_cross_section == 1{


    //load_data ml
    use ml_cross_sectional.dta , replace

    drop if us_hq_all & !us_hq
    gen moved_to_all = us_hq & inlist(migration_state,"CA","MA","NY","NJ","CT","VT","NH","RI")
    gen moved_to_other = us_hq & !inlist(migration_state,"CA","MA","NY","NJ","CT")


    gen moved_to_CA = us_hq & inlist(migration_state,"CA")
    gen moved_to_MA = us_hq & inlist(migration_state,"MA","VT","NH","RI")
    gen moved_to_NY = us_hq & inlist(migration_state,"NY","NJ","CT")


    safedrop ln_first_round ln_initial_pat has_trademarks ln_raised

    gen ln_first_round = ln(first_round +1)
    
    capture gen has_pat = initial_pat > 0
    
    /** Adjust to remove the initial selection **/
    gen post_total_raised = total_raised - first_round
    gen post_final_pat = final_pat - initial_pat
    gen post_final_trademarks = final_trademarks - initial_tr

    gen ln_raised      = ln(post_total_raised +1)
    gen has_trademarks = post_final_trademarks > 0

    gen ln_pat = ln(post_final_pat +1)
    eststo clear	

    foreach depvar in  acquired ln_exit_amount ln_pat  acquired_outside_US ipo ln_raised ln_raised_us_led  has_trademarks {

        if "`depvar'" == "ln_exit_amount" {
            eststo `depvar'_m:  reghdfe `depvar' moved_to_CA moved_to_MA moved_to_NY moved_to_other $ml_us_hq ${ml_`depvar'}   , absorb(company_subsector yr_3-yr_26) cluster(foundation_year  industry)
        }       
        else{
            eststo `depvar'_m:  reghdfe `depvar' moved_to_CA moved_to_MA moved_to_NY moved_to_other $ml_us_hq ${ml_`depvar'}   , absorb(company_subsector  yr_*) cluster(foundation_year  industry)
        }

    }

    esttab   has_trademarks_m ln_pat_m ln_raised_m ln_raised_us_led_m   acquired_m  acquired_outside_US_m ln_exit_amount_m ipo_m   , keep(*moved*) mtitles

    esttab   has_trademarks_m ln_pat_m ln_raised_m ln_raised_us_led_m   acquired_m  acquired_outside_US_m ln_exit_amount_m ipo_m  using "tex/impact_move_CA_not_CA.tex" , keep(*moved*)  mtitle("\makecell{Applied for\\Trademark}" "\makecell{Ln(Patents+1)}" "Ln(VC +1)" "\makecell{Ln(VC +1) \\(US VC Led Only)}"  "Acquired" "\makecell{Acquired \\ by non-US firm}" "Ln(Exit \\$)"  "IPO")  varlabels(moved_to_CA "Moves to California" moved_to_MA "Moves to Massachusetts" moved_to_NY "Moves to New York area" moved_to_other "Moves to other US state")  refcat(moved_to_other "" moved_to_MA "" moved_to_NY ""  , nolabel) se gaps replace prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large The effect of migrating, by US state destination}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table examines whether there are any differences in migration benefits depending on the US location Israeli startups choose. We differentiate between the California, Massachusetts, and New York area (including New Jersey) destination locations, on the one hand, and the remaining US locations, on the other. We examine the same startup performance outcomes as those investigated in Table 3 and Table 6. Standard errors (in parentheses) are double-clustered at founding year and sector levels.  Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01.  " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  label star(* .1 ** .05 *** .01) eqlabels(none) r2



    

		
}






if $r_acq_vs_ipo == 1 {
    clear
    use ml_cross_sectional.dta , replace
    
    gen outcome = 0
    replace outcome = 1 if acquired ==1 & acquirer_is_us == 1
    replace outcome = 2 if acquired == 1 & acquirer_is_us != 1
    replace outcome = 3 if ipo == 1

    safedrop ln_first_round ln_initial_pat ln_initial_tr
    
    gen ln_first_round = ln(first_round +1)
    label variable ln_first_round "Ln(First Round \\$)"
    
    gen ln_initial_pat = ln(initial_pat +1)
    label variable ln_initial_pat "Ln(Initial Patents +1)"


    gen ln_initial_tr = ln(initial_tr +1)
    label variable ln_initial_tr "Ln(Initial Trademakrs +1)"
    
    drop if foundation_year < 1992 | foundation_year > 2010
    
    label define aa  0 "No Exit" 1 "Acquired US" 2 "Acquired Not US" 3 "IPO"
    label values outcome aa

    gen dot_com_boom = inrange(foundation_year, 1995, 2000)
    gen dot_com_bust = inrange(foundation_year, 2001, 2002)


    drop if us_sales_off | us_hq_all & !us_hq
    safedrop moved
    gen moved = us_hq
    label variable moved "Moved"
    
    eststo clear
    eststo: mlogit outcome moved  ln_first_round us_vc_r1 ln_initial_pat ln_initial_tr dot_com_boom dot_com_bust  , vce(cluster foundation_year) iter(40) diff

    eststo: mlogit outcome moved log_p_move c.log_p_move#c.log_p_move , vce(cluster foundation_year) iter(40) diff

    esttab , unstack se label order(*moved*) noomitted  scalar("ll Log Likelihood") mtitles("All Firms" "Only Strategic Controls") eqlabels("Acquired by a US company" "Acquired by a non-US company" "IPO" "Acquired by a US company" "Acquired by a non-US company" "IPO")

    esttab using tex/mlogit_across_outcomes.tex , unstack se label order(*moved*) noomitted  scalar("ll Log Likelihood") replace   star( * .1 ** .05 *** .01) prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large Multinomial Logit Across Outcomes.}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes:}  We report the estimations of a multinomial logit model where the outcome variable takes on value 1 if a startup failed to experience a liquidity event (i.e. either an IPO or an acquisition), 2 if the startup were acquired by a US company, 3 if it were acquired by a non-US company, and 4 if the startup exited through an IPO.  The reference outcome is represented by startups that did not experience a liquidity event. In the first three columns, we consider the entire sample of startups. In the last three columns, we only examine either startups that migrated to the US or startups that could not move for exogenous reasons. Standard errors (in parenthesis) are clustered at the founding-year level. Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01.  " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}") drop(dot_com_*)  mtitles("All Startups" "Only Exogenous Controls") eqlabels("\makecell{Acquired by \\ a US company}" "\makecell{Acquired by \\ a non-US company}" "IPO" "\makecell{Acquired by \\ a US company}" "\makecell{Acquired by \\ a non-US company}" "IPO")



}





if $r_hazard_models == 1 {
    clear
    use ml_cross_sectional.dta , replace
    
    gen exit = Date_exit != .

    eststo clear
    stset years_to_exit   , failure(exit==1)
    eststo: stcox us_hq   log_p_move c.log_p_move#c.log_p_move if (strategic == 1 | us_hq == 1) & in_p_move_range , vce(cluster foundation_year)

    stset years_to_exit     , failure(acquired==1)
    eststo: stcox us_hq  log_p_move c.log_p_move#c.log_p_move  if (strategic == 1 | us_hq == 1) & in_p_move_range , vce(cluster foundation_year)
    
    stset years_to_exit  , failure(ipo==1)
    eststo: stcox us_hq log_p_move c.log_p_move#c.log_p_move    if (strategic == 1 | us_hq == 1) & in_p_move_range , vce(cluster foundation_year)

    esttab, eform

    esttab using tex/hazard_models.tex , eform  keep(us_hq) scalar("ll Log-Likelihood") se mtitle("Exit" "Acquired" "IPO" "US IPO" "Exit" "Acquired" "IPO" "US IPO") prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 	"\caption{\large Hazard of exiting successfully}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: We estimate Cox proportional hazard models on cross-sectional data using the quasi-experimental sample described in Section 4 (Model III). Standard errors (in parentheses) are clustered at the founding year level. We do not estimate the double-LASSO model given that the maximum likelihood estimator would not converge with the inclusion of the several covariates we selected. Significance denoted as:  * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01.  " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")	  varlabels(us_hq "Moves to US") refcat(us_hq "", nolabel) replace
}    



if $r_quasi_experiment_robustness == 1 {


    use ml_cross_sectional.dta , replace
    
    egen year_loc = group(foundation_year location_code)    
    gen moved_dd = us_hq

    
    safedrop ln_first_round  has_trademarks ln_raised

    /** Adjust to remove the initial selection **/
    gen post_total_raised = total_raised - first_round
    gen post_final_pat = final_pat - initial_pat
    gen post_final_trademarks = final_trademarks - initial_tr


    gen ln_first_round = ln(first_round +1)
    gen ln_raised      = ln(post_total_raised +1)
    gen has_trademarks = post_final_trademarks > 0

    
    gen ln_pat = ln(post_final_pat + 1)

    eststo clear
        foreach depvar in  has_trademarks ln_pat ln_raised ln_raised_us_led  acquired acquired_outside_US ln_exit_amount ipo {

            eststo `depvar': reghdfe `depvar' moved_dd log_p_move c.log_p_move#c.log_p_move if (strategic | moved_dd == 1) & in_p_move_range & industry != "IT / Software" , absorb(foundation_year) cluster(foundation_year industry_code)

       }

    esttab, r2 se 
    

   


    	esttab  has_trademarks ln_pat ln_raised ln_raised_us_led    using "tex/robustness_quasi_exp_no_ind.tex" , keep(moved*)  mtitle("\makecell{Applied for\\ Trademark}" "\makecell{Ln(Patents+1)}" "Ln(VC +1)" "\makecell{Ln(VC +1) \\(US VC Led Only)}" "Acquired" "\makecell{Acquired \\ Outside US}" "Ln(Exit \\$)" "IPO")  label se refcat(  moved_dd "\emph{Model II: Quasi-Experiment}" , nolabel) replace  	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large  The effect of migrating to the US on Israeli startups' intermediary outcomes: Quasi-experiment having excluded IT \& software startups from the sample.}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the estimates for the impact of migrating on the startups' intermediary performance outcomes. The first performance measure is an indicator for whether a startup applied for a trademark with the USPTO after \$t+1\$, where \$t\$ is the startup's founding year (column (1)). The second measure is the number of US granted patents a startup applied for, again after \$t+1\$ (column (2)). The third and fourth outcomes are the amount of VC raised after the first financing round (column (3)) and the amount of US VC raised during the same period (column (4)), respectively. We report the results from our quasi-experiment, having excluded IT \& software startups from the sample. Standard errors (in parentheses) are double-clustered at founding year and sector levels. Significance noted as: *p  \textless  0.10; **p \textless  0.05; ***p \textless  0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  varlabels( moved_dd "Moves to US") star(* .1 ** .05 *** .01) eqlabels(none) r2

        	esttab  acquired acquired_outside_US ln_exit_amount ipo    using "tex/robustness_quasi_exp_no_ind_equity.tex" , keep(moved*)  mtitle( "Acquired" "\makecell{Acquired \\ Outside US}" "Ln(Exit \\$)" "IPO")  label se refcat(  moved_dd "\emph{Model II: Quasi-Experiment}" , nolabel) replace  	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large The effect of migrating to the US on Israeli startups' equity outcomes: Quasi-experiment having excluded IT \& software startups from the sample}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the estimates for the impact of migrating on startup equity outcomes. The outcomes are: the likelihood that a startup is acquired (column (1)), the likelihood it is acquired by a non-US company (column (2)), a startups' sales value (column(3)), and the likelihood it exits through an IPO (column (4)). We report the results from our quasi-experiment, having excluded IT \& software startups from the sample. Standard errors (in parentheses) are double-clustered at founding year and sector levels. Significance noted as: *p \textless 0.10; **p \textless 0.05; ***p \textless 0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  varlabels( moved_dd "Moves to US") star(* .1 ** .05 *** .01) eqlabels(none) r2 


}    



if $r_appendix_cem == 1 {

    use ml_cross_sectional.dta , replace
    sum ones
    global total_obs `r(N)'
    


    gen moved_lasso = us_hq
    drop if moved_lasso==.
    gen foundation_year1=foundation_year
    replace foundation_year1=1994 if foundation_year1<1994
    gen final_trademarksb=final_trademarks>0
    gen linitial_pat=ln(initial_pat+1)

   encode industry, gen(sector)

   
   gen has_initial_tr = initial_tr > 0
   set seed 123456789


   gen has_trademarks = final_trademarksb
   gen ln_pat = ln_final_patents


   label variable moved_lasso "Moves to US"
   cem sector foundation_year1 us_vc_r1 has_pat  ml_log_amount_raised(#5) sector , treatment(moved_lasso) k2k
   eststo clear
    foreach depvar in    has_trademarks ln_pat ln_raised ln_raised_us_led  acquired   acquired_outside_US ipo  {
        eststo `depvar':reghdfe `depvar' moved_lasso has_initial_tr ml_log_amount_raised linitial_pat if cem_matched == 1, a(cem_strata company_subsector foundation_year) vce(cluster foundation_year sector)               
    }

    esttab , keep(moved*) star(* .1 ** .05) p



       esttab     using "tex/appendix.cem.tex" , keep(*moved*)  mtitle("\makecell{Applied for\\Trademark}" "\makecell{Ln(Patents+1)}" "Ln(VC +1)" "\makecell{Ln(VC +1) \\(US VC Led Only)}"  "Acquired" "\makecell{Acquired \\ by non-US firm}" "IPO")  se gaps replace prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large Coarsened exact matching cross-sectional estimates}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: We implement a coarsened exact matching algorithm and construct a sample that matches migrants on sector, founding year, amount of US VC raised in the first round, total amount raised, and whether a startup applied for a US granted patent at founding or the year after. Standard errors (in parentheses) are double-clustered at founding year and sector levels.  Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01.  " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  label star(* .1 ** .05 *** .01) eqlabels(none) r2




   
}






if $r_reviewer_table_subsector == 1 {

    //load_data ml
    use ml_cross_sectional.dta , replace

    sum ones
    global total_obs `r(N)'
    
    egen year_loc = group(foundation_year location_code)
    
    gen moved_lasso = us_hq
    gen moved_lasso2 = us_hq

    gen ln_total_raised = ln(total_raised)

    
    /** Adjust to remove the initial selection **/
    gen post_total_raised = total_raised - first_round
    gen post_final_pat = final_pat - initial_pat
    gen post_final_trademarks = final_trademarks - initial_tr



    safedrop ln_first_round ln_raised has_trademarks ln_pat
    gen ln_first_round = ln(first_round +1)
    gen ln_raised      = ln(post_total_raised +1)
    gen has_trademarks = post_final_trademarks > 0

    
    gen ln_pat = ln(post_final_pat + 1)

        /** First, load a bunch of important stuff necessary to run the regressions **/
    foreach depvar in    has_trademarks ln_pat ln_raised ln_raised_us_led  acquired ln_exit_amount  acquired_outside_US ipo {
        
         if "${ml_`depvar'}" == "" {
            di "Running lasso for dep var = `depvar'"
            lassoShooting `depvar' ml_* ,  lasiter(100) verbose(0) controls(yr_*)
            file open f using selected_ml.do , write append
            file write f "global ml_`depvar' `r(selected)'" _n
            file close f
            do selected_ml.do
        }

        local us_hq_Selected ${ml_us_hq}
        local depvar_selected ${ml_`depvar'}
        local lasso_vars_dup  `us_hq_Selected' `depvar_selected'
        loc lasso_vars : list uniq lasso_vars_dup


        eststo `model_name'_1: reghdfe `depvar' moved_lasso  `lasso_vars'   , absorb(yr_*) cluster(foundation_year  industry_code)
       

       

        local us_hq_Selected ${ml_hq_subsector}
        local depvar_selected ${ml_`depvar'}
        local lasso_vars_dup  `us_hq_Selected' `depvar_selected'
        loc lasso_vars : list uniq lasso_vars_dup

        eststo `model_name'_2:  reghdfe `depvar' moved_lasso2  `lasso_vars'   , absorb(company_subsector yr_*) cluster(foundation_year  industry_code)
        
        di "Merging models under `merged_name'" 
        
        eststo `depvar': appendmodels `model_name'_1 `model_name'_2   


    }

	


//    esttab  acquired_m ln_exit_amount_m acquired_outside_US_m ipo_m    , keep(moved*)  mtitle( "1[Acquired]" "Ln(Exit \\$)" "1[Acquire  d Outside U.S.]" "1[IPO]")  label se refcat(moved_naive "Model 1: Naive" moved_matched "Model 2: Matching" moved_dd "Model 3: DiD", nolabel) replace noobs   varlabels(moved_naive "Moves to US" moved_matched "Moves to US" moved_dd "Moves to US") star(* .1 ** .05 *** .01)
	

	esttab    has_trademarks ln_pat ln_raised ln_raised_us_led  acquired ln_exit_amount  acquired_outside_US ipo   using "tex/reviewer.with_and_without_subsector_fe.tex" , keep(moved*)  mtitle("\makecell{Applied for\\ Trademark}" "\makecell{Ln(Patents+1)}" "Ln(VC +1)" "\makecell{Ln(VC +1) \\(US VC Led Only)}" "Acquired" "\makecell{Acquired \\ by non-US firm}" "Ln(Exit \\$)"  "IPO")  label se refcat(moved_lasso "\emph{Model II old (no subsector F.E.): Double-LASSO}"   moved_lasso2 "\emph{Model II new (subsector F.E.): Double-LASSO}"  , nolabel) replace noobs 	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large Double-LASSO model with and without subsector fixed-effects.}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}:  Significance denoted as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  varlabels(  moved_lasso "Moves to US" moved_lasso2 "Moves to US" ) star(* .1 ** .05 *** .01) eqlabels(none) 


}

if $r_appendix_year_outcomes == 1 {

       clear
        use migration_panel.dta 

       gen moved_all = age >= age_move
        replace moved_ = 0 if us_hq == 0
        drop if age > 7
    
	label variable moved_ "Has Moved"
	label variable age "Age"

	rename ln_cum_raised_us_led ln_r_us


        forvalues i=0/7 {
            gen age_moved_`i' = moved_ & age == `i'
            label variable age_moved_`i' "Age = `i' X Has Moved"
        }

        xtset firm_id age

        gen t_trademark = ln_t_trademarks > 0

        drop if acquired_ | ipo_ | F.acquired_ | F.ipo_

        bysort firm_id: egen max_raised = max(cum_raised)
        drop if max_raised == 0
    
        gen ln_t_raised_us = ln(fin_raised_us_ + 1)


        gen year = foundation_year + age
//        drop if year >= (year(Date_exit)-1) & ceased_to_operate == 1

    
	eststo clear
	foreach v of varlist  ln_t_raised ln_t_raised_us  {
            eststo `v'1: reghdfe `v' moved_ if us_sales_off==0 &( !us_hq_all | us_hq), absorb( firm_id age age_move) cluster(foundation_year)

            eststo `v'2: reghdfe `v' moved_all, absorb( firm_id age age_move) cluster(foundation_year)

	}
        





        esttab  ln_t_raised1 ln_t_raised_us1  ln_t_raised2 ln_t_raised_us2    using "tex/appendix.panel_by_period.tex" ,   drop ( _cons ) mtitle(     "\makecell{Log (VC+1)}"     "\makecell{Log (US VC+1)}"      "\makecell{Log (VC+1) \\ Incl. Late Movers}"     "\makecell{Log (US VC+1)  \\ Incl. Late Movers}"   )  label se   	refcat(moved_ "\emph{Model I: Main Difference}" , nolabel) replace noobs prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" 	"\caption{\large The effect of migrating to the US on Israeli startups' yearly financing outcomes}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the estimates for the impact of migrating on a startup's yearly amount of financing raised, exploiting within migrant variation. \emph{Has Moved} is an indicator that takes on value 1 starting from the year in which a startup established its headquarters in the US and zero in the pre-migration period. The results in columns (1) and (2) are for the same sample as in Table 4. The results in columns (3) and (4) are for a sample including startups that migrated after their third year of age. Standard errors (in parentheses) are double-clustered at founding year and sector levels. Significance denoted as: * p \textless 0.1, ** p \textless 0.05, *** p \textless 0.01. " "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")	   star(* .1 ** .05 *** .01)   r2   varlabels(moved_all "Has Moved")

}


if $r_reviewer_per_period == 1 {
    
}
 
if $r_dlasso_with_subsec_fe == 1{
    //load_data ml
    use ml_cross_sectional.dta , replace
    
    do selected_ml.do
    
    sum ones
    global total_obs `r(N)'
    
    egen year_loc = group(foundation_year location_code)
    gen moved_lasso = us_hq
    
    safedrop ln_first_round  has_trademarks ln_raised

    /** Adjust to remove the initial selection **/
    gen post_total_raised = total_raised - first_round
    gen post_final_pat = final_pat - initial_pat
    gen post_final_trademarks = final_trademarks - initial_tr


    gen ln_first_round = ln(first_round +1)
    gen ln_raised      = ln(post_total_raised +1)
    gen has_trademarks = post_final_trademarks > 0

    
    gen ln_pat = ln(post_final_pat + 1)


    tab company_subsector , gen (mls_)
    capture do selected_ml_with_subsectorfe.do


    if "${ml_us_hq_sb}" == "" {
            di "Running lasso with subsector fe for dep var = `depvar'"
            lassoShooting us_hq ml_* mls_* ,  lasiter(100) verbose(0) controls(yr_*)
            file open f using selected_ml_with_subsectorfe.do , write append
            file write f "global ml_us_hq_sb `r(selected)'" _n
            file close f
            do selected_ml_with_subsectorfe.do
    }

    eststo clear
    foreach depvar in  has_trademarks ln_pat ln_raised ln_raised_us_led  acquired   acquired_outside_US ipo {

        local model_name `depvar'_
        local merged_name `depvar'_m
        di "Running models under `merged_name'" 
        
         if "${ml_`depvar'_sb}" == "" {
            di "Running lasso with subsector fe for dep var = `depvar'"
            lassoShooting `depvar' ml_* mls_* ,  lasiter(100) verbose(0) controls(yr_*)
            file open f using selected_ml_with_subsectorfe.do , write append
            file write f "global ml_`depvar'_sb `r(selected)'" _n
            file close f
            do selected_ml_with_subsectorfe.do
        }

        local us_hq_Selected ${ml_us_hq_sb}
        local depvar_selected ${ml_`depvar'_sb}
        local lasso_vars_dup  `us_hq_Selected' `depvar_selected'
        loc lasso_vars : list uniq lasso_vars_dup

        local reg_lasso reghdfe `depvar' moved_lasso  `lasso_vars'   , absorb(yr_* company_subsector) cluster(foundation_year  industry_code)
        eststo `model_name': `reg_lasso'
    }





    

    
    esttab    using "tex/appendix.double_lasso_with_lasso_subsector_fe.tex" , keep(moved*)   mtitle("\makecell{Applied for\\Trademark}" "\makecell{Ln(Patents+1)}" "Ln(VC +1)" "\makecell{Ln(VC +1) \\(US VC Led Only)}"  "Acquired" "\makecell{Acquired \\ by non-US firm}" "IPO")  label se refcat(moved_lasso "\emph{Double-LASSO}" , nolabel) replace noobs 	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large The effect of migrating to the US on Israeli startups' performance outcomes: With subsector fixed effects in the LASSO variable selection}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the estimates for the impact of migrating on startup performance estimating a double-LASSO model that includes subsector fixed effects in the variable selection process of both the selection and treatment equations. We control for subsector and founding year fixed effects. Standard errors (in parentheses) are double-clustered at founding year and sector levels. Significance denoted as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  varlabels(moved_naive "Moves to US"  moved_lasso "Moves to US" moved_dd "Moves to US")  star(* .1 ** .05 *** .01) eqlabels(none) r2 



}


if $r_reviewer_equity_lasso == 1 {
    //load_data ml
    use ml_cross_sectional.dta , replace

    sum ones
    global total_obs `r(N)'
    
    egen year_loc = group(foundation_year location_code)
    
    gen moved_lasso = us_hq
    gen ln_total_raised = ln(total_raised+1)
    
        /** First, load a bunch of important stuff necessary to run the regressions **/
    eststo clear
    foreach depvar in  acquired   acquirer_is_us ipo {
         local model_name `depvar'_
        local merged_name `depvar'_m

        
         if "${ml_`depvar'}" == "" {
            di "Running lasso for dep var = `depvar'"
            lassoShooting `depvar' ml_* ,  lasiter(100) verbose(0) controls(yr_*)
            file open f using selected_ml.do , write append
            file write f "global ml_`depvar' `r(selected)'" _n
            file close f
            do selected_ml.do
        }

        local us_hq_Selected ${ml_us_hq}
        local depvar_selected ${ml_`depvar'}
        local lasso_vars_dup  `us_hq_Selected' `depvar_selected'
        loc lasso_vars : list uniq lasso_vars_dup



        local reg_lasso reghdfe `depvar' moved_lasso   ln_raised_us_led ln_final_pat  has_trademark   `lasso_vars'   , absorb(company_subsector yr_*) cluster(foundation_year  industry_code)
        eststo `model_name'_3: `reg_lasso'

    }


    esttab, keep(moved_lasso ln_* has_trademark) se star(* .1 ** .05) 
	


    esttab       using "tex/appendix.equity_controlling_for_vc.tex" , keep(moved* ln_raised_us_led ln_final_patents has_trademark)  mtitle("Acquired" "\makecell{Acquired \\ by US firm}" "IPO")  label se refcat(moved_lasso "\emph{Model II: Double-LASSO (N=$total_obs)}" , nolabel) replace noobs 	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large The effect of migrating to the US on Israeli startups' equity outcomes controlling for intermediate performance outcomes}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" )	  	postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table reports the effects of migrating on the startups' equity outcomes controlling for intermediate performance measures such as VC fundraising, patenting, and trademarks in the double-LASSO model. We include founding year and subsector fixed effects. Standard errors (in parentheses) are double-clustered at founding year and sector levels. Significance denoted as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  varlabels(  moved_lasso "Moves to US" ln_raised_us_led "Ln(VC Raised in US +1)" ln_final_patents "Ln(Patents +1)" has_trademark "Has Trademark") star(* .1 ** .05 *** .01) eqlabels(none) 


}


if $r_nonmover_quasi_exp_outcomes == 1 {
    use ml_cross_sectional.dta , replace

    sum ones
    global total_obs `r(N)'
    
    egen year_loc = group(foundation_year location_code)
    
    gen moved_dd = us_hq
    
    safedrop ln_first_round  has_trademarks ln_raised

    /** Adjust to remove the initial selection **/
    gen post_total_raised = total_raised - first_round
    gen post_final_pat = final_pat - initial_pat
    gen post_final_trademarks = final_trademarks - initial_tr


    gen ln_first_round = ln(first_round +1)
    gen ln_raised      = ln(post_total_raised +1)
    gen has_trademarks = post_final_trademarks > 0

    
    gen ln_pat = ln(post_final_pat + 1)
    label variable strategic "Restricted Subsector"



    gen exit = acquired | ipo


    eststo clear
    foreach depvar in  ln_raised acquired   acquired_outside_US ipo  exit  {

        eststo `depvar': reghdfe `depvar' strategic  if in_p_move & us_sales_off ==0  & us_hq == 0, cluster(foundation_year) absorb(foundation_year industry)
                
    }


    esttab , keep(strategic) star(* .1 ** .05) p


    
    esttab    using "tex/strategic_non_movers.tex" , keep(strategic)  mtitle( "Ln(VC +1)"  "\makecell{Acquired}"    "\makecell{Acquired \\ Outside US}"  "\makecell{IPO}" "\makecell{Exit}" "\makecell{Ceased to \\ Operate}")  label se  replace noobs 	prehead("\begin{table} \centering" "\begin{threeparttable}" "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" "\caption{\large Performance of stayers, distinguishing between restricted and non-restricted subsectors}" "\begin{tabular}{l*{@M}{rcccccc}} \hline \hline" ) postfoot("\hline\hline" "\end{tabular}" " \begin{tablenotes} \item \emph{Notes}: This table compares the performance of quasi-exogenous stayers with that of non-exogenous stayers.  The latter operate in the same sectors as the quasi-exogenous stayers, but belong to non-restricted subsectors. Only those firms in the region of common support of the quasi-experiment are included.  Founding year and sector fixed effects are used. Standard errors are clustered at the founding year level. Significance denoted as: * p \textless 0.10, ** p \textless 0.05, *** p \textless 0.01." "\end{tablenotes}" "\end{threeparttable}"  "\end{table}")  star(* .1 ** .05 *** .01) eqlabels(none) 



}



capture log close
